package cn.fintecher.pangolin.entity.mysql;

import cn.fintecher.pangolin.common.enums.BaseSelect;
import cn.fintecher.pangolin.common.enums.BaseStatus;
import cn.fintecher.pangolin.common.enums.DepartmentCollectionType;
import cn.fintecher.pangolin.common.enums.DepartmentType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;
import java.util.Date;

/**
 * @Auther: xiaqun
 * @Description: 部门实体
 * @Date: 9:48 2019/8/13
 */

@Data
@Entity
@Table(name = "department")
@ApiModel(value = "department", description = "部门实体")
public class Department extends BaseEntity {
    @ApiModelProperty(value = "机构名称")
    private String name;

    @ApiModelProperty(value = "机构code")
    private String departCode;

    @ApiModelProperty(value = "机构级别")
    private Integer level;

    @ApiModelProperty(value = "机构状态")
    @Enumerated(EnumType.STRING)
    private BaseStatus status;

    @ApiModelProperty(value = "父级机构ID")
    private String parentId;

    @ApiModelProperty(value = "机构类型")
    @Enumerated(EnumType.STRING)
    private DepartmentType type;

    @ApiModelProperty(value = "催收类型")
    @Enumerated(EnumType.STRING)
    private DepartmentCollectionType collectionType;

    @ApiModelProperty(value = "地址")
    private String address;

    @ApiModelProperty(value = "联系人")
    private String contact;

    @ApiModelProperty(value = "联系电话")
    private String contactNo;

    @ApiModelProperty(value = "创建人ID")
    private String operatorId;

    @ApiModelProperty(value = "创建时间")
    private Date operateTime;

    @ApiModelProperty(value = "更新人ID")
    private String updaterId;

    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @ApiModelProperty(value = "是否为系统部门")
    @Enumerated(EnumType.STRING)
    private BaseSelect isSystem = BaseSelect.NO;

    /**
     * 处理创建人、更新人、创建时间、更新时间
     *
     * @param id   用户ID
     * @param date 时间
     * @param b    标识 true时设置创建人和创建时间
     */
    public void process(String id, Date date, boolean b) {
        if (b) {
            this.operatorId = id;
            this.operateTime = date;
        }
        this.updaterId = id;
        this.updateTime = date;
    }
}
